package com.ruoyi.project.his.system.controller;

import com.ruoyi.common.utils.SecurityUtils;
import com.ruoyi.framework.aspectj.lang.annotation.Log;
import com.ruoyi.framework.aspectj.lang.enums.BusinessType;
import com.ruoyi.framework.web.controller.BaseController;
import com.ruoyi.framework.web.domain.AjaxResult;
import com.ruoyi.framework.web.page.TableDataInfo;
import com.ruoyi.project.his.system.domain.HisDepartment;
import com.ruoyi.project.his.system.domain.HisRegistryCost;
import com.ruoyi.project.his.system.service.IHisRegistryCostService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/his/registryCost")
public class HisRegistryCostController extends BaseController {
    //声明业务层属性
    @Autowired
    private IHisRegistryCostService iHisRegistryCostService;
    /**
     * 获取挂号费用列表
     */
    // @PreAuthorize("@ss.hasPermi('system:post:list')")
    @GetMapping("/list")
    public TableDataInfo list(HisRegistryCost hisRegistryCost)
    {
        startPage();
        List<HisRegistryCost> hisRegistryCosts = iHisRegistryCostService.selectHisRegistryCostList(hisRegistryCost);
        return getDataTable(hisRegistryCosts);
    }
    /**
     * 新增挂号费信息
     * @RequestBody 表明请求数据就是请求体 请求数据就是一个大json、
     *
     */
    //@PreAuthorize("@ss.hasPermi('system:post:add')")
    @Log(title = "挂号费管理", businessType = BusinessType.INSERT)
    @PostMapping("/addRegistryCost")
    public AjaxResult add(@RequestBody HisRegistryCost hisRegistryCost) {

        hisRegistryCost.setCreateBy(SecurityUtils.getUsername());

        return toAjax(iHisRegistryCostService.insertHisRegistryCost(hisRegistryCost));
    }
    /**
     * 根据挂号费编号获取详细信息
     */
    // @PreAuthorize("@ss.hasPermi('system:post:query')")
    @GetMapping(value = "/{registryCostId}")
    public AjaxResult getInfo(@PathVariable Long registryCostId)
    {
        return AjaxResult.success(iHisRegistryCostService.selectRegistryCostById(registryCostId));
    }

    /**
     * 修改科室
     */
    // @PreAuthorize("@ss.hasPermi('system:post:edit')")
    @Log(title = "挂号费管理", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit( @RequestBody HisRegistryCost hisRegistryCost)
    {
        hisRegistryCost.setUpdateBy(SecurityUtils.getUsername());//给接请求数据实体类赋默认值，谁改的的是谁
        return toAjax(iHisRegistryCostService.updateRegistryCost(hisRegistryCost));
    }
    /**
     * 删除挂号费
     */
    // @PreAuthorize("@ss.hasPermi('system:post:remove')")
    @Log(title = "挂号费管理", businessType = BusinessType.DELETE)
    @DeleteMapping("/{registryCostIds}")
    public AjaxResult remove(@PathVariable Long[] registryCostIds)
    {
        return toAjax(iHisRegistryCostService.deleteRegistryCostByIds(registryCostIds));
    }
}
